package org.xliu.cs.openproject.codegenerator.restapi;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.List;

/**
 * API描述信息
 */
public class ApiDescription {
    @JsonProperty("service")
    private ServiceInfo service;
    
    @JsonProperty("apis")
    private List<ApiInfo> apis;

    public ApiDescription() {
    }

    public static ApiDescription fromJsonNode(JsonNode apiDescriptionNode, ObjectMapper objectMapper) throws IOException {
        // 直接使用ObjectMapper将JsonNode转换为ApiDescription对象
        return objectMapper.treeToValue(apiDescriptionNode, ApiDescription.class);
    }

    // Getters and setters
    public ServiceInfo getService() {
        return service;
    }

    public void setService(ServiceInfo service) {
        this.service = service;
    }

    public List<ApiInfo> getApis() {
        return apis;
    }

    public void setApis(List<ApiInfo> apis) {
        this.apis = apis;
    }
}